#!/bin/sh
#
# mount, umount & losetup are core scripts
#

# debian: /etc/init.d/hwclock.sh conflicts with rc.country
rm -rf etc

for i in bin sbin usr/bin usr/sbin
do
	[ -d $i ] || continue
	[ -h $i ] && continue
	[ -f ${i}/mount ] && mv ${i}/mount bin/mount-FULL
	[ -f ${i}/umount ] && mv ${i}/umount bin/umount-FULL
	[ -f ${i}/losetup ] && mv ${i}/losetup sbin/losetup-FULL
done

#delete invalid symlinks
find -L . -type l -delete

# util-linux has 'rename.ul', presume ubuntu have renamed it so as not to conflict
# with some other 'rename'....
find . -type f -name '*.ul' | while read file ; do
	mv -f $file ${file%.ul}
done

#===============================================================

rm -rf ${PLIB}/udev ${PLIB}/systemd

mkdir -p var/lock

# currently these apps are busybox applets...

for i in \
	chrt \
	dmesg \
	fdformat \
	fsck.minix \
	fstrim \
	getty \
	ionice \
	ipcrm \
	ipcs \
	logger \
	mesg \
	mkfs.minix \
	mkfs.cramfs \
	mkfs.bfs \
	more \
	nsenter \
	pivot_root \
	readprofile \
	renice \
	rtcwake \
	sulogin \
	switch_root \
	taskset \
	wall
do

	for d in bin sbin usr/bin usr/sbin usr/local/bin
	do
		if [ -f ${d}/${i} -o -L ${d}/${i} ] ; then
			rm -fv ${d}/${i}
		fi
	done

done
